/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package servidor;

import org.omg.CORBA.ORB;
import org.omg.CosNaming.NameComponent;
import org.omg.CosNaming.NamingContextExt;
import org.omg.CosNaming.NamingContextExtHelper;
import org.omg.PortableServer.POA;
import org.omg.PortableServer.POAHelper;
import sop_corba.Juego;
import sop_corba.JuegoHelper;

/**
 *
 * @author familia
 */
public class Servidor {
     public static void main(String args[])
    {
	try {
	    ORB orb = ORB.init(args, null);

	    POA rootpoa = POAHelper.narrow(orb.resolve_initial_references("RootPOA"));
	    rootpoa.the_POAManager().activate();

	    JuegoImpl obj = new JuegoImpl();
	    
	    org.omg.CORBA.Object ref = rootpoa.servant_to_reference(obj);
	    Juego cref = JuegoHelper.narrow(ref);

	    org.omg.CORBA.Object objRef =
		           orb.resolve_initial_references("NameService");
	    NamingContextExt ncRef = NamingContextExtHelper.narrow(objRef);

	    String name = "jppt";
	    NameComponent path[] = ncRef.to_name(name);
	    ncRef.rebind(path, cref);

	    orb.run();
	}

	catch(Exception e) {
	    System.err.println("ERROR : " + e);
	    e.printStackTrace(System.out);
	}
    }
    
    
}
